package com.tensquare.gathering.controller;

import com.tensquare.gathering.pojo.Gathering;
import com.tensquare.gathering.service.GatheringService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Date 2021/3/21 19:49
 */
@RestController
@CrossOrigin
@RequestMapping("/gathering")
public class GatheringController {
    @Autowired
    private GatheringService gatheringService;


    /***
     * 根据id查询活动
     * Param: [label]
     **/
    @GetMapping("/{gatheringId}")
    public Result findById(@PathVariable String gatheringId) {
        return new Result(true, StatusCode.OK, "查询成功", gatheringService.findById(gatheringId));
    }

    /***
     * 根据id更新活动信息
     * Param: [label]
     **/
    @PutMapping("/{gatheringId}")
    public Result updateById(@RequestBody Gathering gathering, @PathVariable String gatheringId) {
        gathering.setId(gatheringId);
        gatheringService.updateById(gathering);
        return new Result(true, StatusCode.OK, "查询成功");
    }
}
